package com.atguigu.spzx.common.exception;

import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.common.ResultCodeEnum;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@ControllerAdvice
public class GlobalException {


    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result error(Exception e) {
        return Result.build(e.getMessage(), ResultCodeEnum.LOGIN_AUTH);
    }


    @ExceptionHandler(value = SPZXException.class)
    @ResponseBody
    public Result error(SPZXException e) {
        return Result.build(null, e.getResultCodeEnum());

    }


}
